package com.cloudcreativity.blyg.ui.user;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.cloudcreativity.blyg.R;
import com.cloudcreativity.blyg.base.BaseActivity;
import com.cloudcreativity.blyg.databinding.ActivityLoginBinding;
import com.cloudcreativity.blyg.ui.MainActivity;
import com.cloudcreativity.blyg.utils.SPUtils;

public class LoginAC extends BaseActivity {

    private ActivityLoginBinding binding;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if(SPUtils.get().isLogin()){
            startActivity(new Intent(this, MainActivity.class));
            finish();
        }

        binding = DataBindingUtil.setContentView(this, R.layout.activity_login);
        binding.setModel(new LoginModel(this, binding,this));
    }

    @Override
    protected void onResume() {
        super.onResume();
        if(binding!=null){
            binding.vvLogin.start();
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if(binding!=null){
            binding.vvLogin.pause();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(binding!=null){
            binding.vvLogin.pause();
        }
    }
}
